/*
 * functions.h
 *
 *  Created on: 2011-11-25
 *      Author: xugp
 */

#ifndef FUNCTIONS_H_
#define FUNCTIONS_H_

typedef struct _user_t{
	char userid[100];
	int fd;
	char roomid[50];
}user_t;

typedef struct _room_t{
	char roomid[100];
	list_t *userlist;
} room_t;

typedef void(*func)(request_t*);



extern hashtable_t * g_connectiontable;
extern list_t * g_connectionlist;
extern list_t *g_requestlist;

void initfuntable();
void do_login(request_t* pRequest);
void do_joinroom(request_t*pRequest);
void do_exitroom(request_t* pRequest);
void do_logout(request_t* pRequest);
void do_sendmsg(request_t* pRequest);
void do_roommsg(request_t* pRequest);
void do_something(request_t* pRequest);
void do_roomuserlist(request_t* pRequest);
void do_roomusercount(request_t* pRequest);
void do_sendroommsg(request_t* pRequest);
void do_heart(request_t* pRequest);
void do_checkuser(request_t *pRequest);
void do_sendsysmsg(request_t *pRequest);

void do_killuser(request_t* pRequest);
void do_stats(request_t* pRequest);
//系统用
void closeconnection(int fd);

func getfunction(char * cmd);
user_t * getuserfromfd(int fd);
connection_t * getconnectionfromfd(int fd);

//flag:0只获取到下一个空格，flag：1获取到结尾
char * getparam(char * param,size_t paramlen,int index,int flag, char * paramstring);

#endif /* FUNCTIONS_H_ */
